package com.lad.controller;

import com.lad.annotation.ResponseResult;
import com.lad.exception.ApiException;
import com.lad.fegin.ProviderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luheng
 * @create 2021-01-20 22:53
 */
@RestController
@RefreshScope
public class ConsumerController {
    @Autowired
    ProviderFeignService providerFeignService;

    @GetMapping("/test111")
    @ResponseResult
    public String testResponseResult(String flag) {
        if ("1".equals(flag)) {
            throw new ApiException("error...");
        }
        return "ok";
    }

    @GetMapping("/test")
    public String test() {
        return providerFeignService.test();
    }

    @Value("${user.name1}")
    String name1;

    @GetMapping("/getName")
    public String getName() {
        return name1;
    }
}
